/*
 * @Author: cest cestrmail@163.com
 * @Date: 2022-12-12 09:01:50
 * @LastEditors: cest cestrmail@163.com
 * @LastEditTime: 2022-12-12 09:27:56
 * @FilePath: /ithome-lite/src/utils/request.ts
 * @Description: request -- fly
 */
import Fly from 'flyio'

const request = new Fly()

request.interceptors.request.use((request: any) => {
  uni.showNavigationBarLoading()
  return request
})

request.interceptors.response.use(
  (response:any, promise:any) => {
    uni.hideNavigationBarLoading()
    return promise.resolve(response.data)
  },
  (err:any, promise:any) => {
    uni.hideNavigationBarLoading()
    uni.showToast({
      title: err.message,
      icon: 'none'
    })
    return promise.resolve()
  }
)

export default request
